//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
import gridHeader from "./order/vsmallorder.vue";
import orderDetails from "./order/information.vue";
let extension = {
  components: {
    //动态扩充组件或组件路径
    //表单header、content、footer对应位置扩充的组件
    gridHeader: gridHeader, //{ template: "<div>扩展组xx件</div>" },
    gridBody: orderDetails,
    gridBody: "",
    gridFooter: "",
    //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
    modelHeader: "",
    modelBody: "",
    modelFooter: ""
  },
  buttons: { view: [], box: [], detail: [] }, //扩展的按钮
  methods: {
    //事件扩展
    onInit() {
      //缓存当前对象
      this.$store.getters.data().viewPageTests = this;
      // this.$store.getters.data().viewPageTest=this;
      // this.single=true;
      // this.textInline=true;
      // this.ck=false;
      // this.columnIndex = true;
      this.maxBtnLength = 4;
      this.boxOptions.height = 450;
      this.boxOptions.width = 900;
      // this.pagination.sortName = "createDate";  //设置排序字段
      //  this.pagination.order = "desc" ; //排序方式desc或者asc
      console.log(this.columns);
      this.columns.forEach(element => {
        element.disabled = true;
        // console.log(element)
      });
      this.columns.push({
        title: "操作",
        fixed: "right",
        width: 160,
        render: (h, { row, column, index }) => {
          return h("div", { style: {} }, [
            h(
              "a",
              {
                props: {},
                style: {},
                on: {
                  click: e => {
                    this.$refs.gridHeader.openOld(row);
                  }
                }
              },
              "    查看旧订单"
            ),
            h(
              "a",
              {
                props: {},
                style: {},
                on: {
                  click: e => {
                    console.log(this.$refs.gridHeader);
                    this.$refs.gridHeader.open6(row);
                  }
                }
              },
              "    操作订单"
            ),
            // h(
            //   "a",
            //   {
            //     props: {},
            //     style: {},
            //     on: {
            //       click: e => {
            //         this.$refs.gridHeader.open8(row);
            //         // this.linkData(row);
            //       }
            //     }
            //   },
            //   "    报名单信息"
            // )
          ]);
        }
      });
    },
    // 点击多选框
    // rowChange(row) {
    //   if(row.apply_order_status!=0){this.$Message.error("请选择未合并的订单！");this.$refs.table.$refs.table.toggleRowSelection(row)}
    //   return false;
    // },
    // 点击行
    rowClick({ row, column, event }) {
      //查询界面table点击行选中当前行
      // console.log(column,event)
      //  if(row.apply_order_status==0){this.$refs.table.$refs.table.toggleRowSelection(row)}
      //   // else{this.$Message.error("请选择未合并的订单！")}
      //   return true;
    },
    updataBatch(e) {
      console.log(e, "我是父组件");
      this.log(this.$refs.detail.rowData);
    },
    addBefore(e) {
      console.log(formData);

      e.detailData = [];
      return true;
    },
    searchAfter(result) {
      result.forEach(item => {
        if (item.apply_order_status == 1) {
          item.DISABLED = true;
        }
        if (item.title) {
          let product_name = item.product_name + '|'
          item.title = item.title.replace(product_name, '')
        }
      });
      return true;
    },
    merge() {
      let list = [];
      console.log(this.$refs.table.getSelected());

      let selectedlist = this.$refs.table.getSelected();

      if (selectedlist.length > 0) {
        selectedlist.forEach(item => {
          list.push(item.order_number);
        });

        this.$confirm("转订单, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          customClass: "del-model",
          type: "warning"
        }).then(() => {
          this.http
            .post("api/VSmallOrdersApply/UpdateOrderStatus", list, false)
            .then(res => {
              if (res.code == 200) {
                this.$Message.success(res.message);

                this.$store.getters.data().viewPageTests.refresh();
              } else {
                this.$Message.error(res.message);
              }
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "已取消转订单"
              });
            });
          // this.$Message.info(res.message);
        });
      } else {
        this.$error("只能选中至少一行进行转订单");
      }
    }
  }
};
export default extension;
